package com.crm.vo;

import cn.hutool.core.io.FileUtil;
import cn.hutool.core.util.ObjectUtil;
import com.crm.entity.CrmMenu;
import lombok.Data;

import java.io.File;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;


@Data
public class SysMenu implements Serializable {

    public SysMenu() {
    }

    public SysMenu(CrmMenu crmMenu) {
        if (ObjectUtil.isNotNull(crmMenu)) {
            this.id = crmMenu.getId();
            this.name = crmMenu.getName();
            this.icon = crmMenu.getIcon();
            this.parentId = crmMenu.getParentId();
            this.orderNum = crmMenu.getOrderNum();
            this.component = crmMenu.getComponent();
            this.path = crmMenu.getPath();
            this.menuType = crmMenu.getMenuType();
            this.perms = crmMenu.getPerms();
        }
    }

    public CrmMenu getCrmMenu() {
        CrmMenu crmMenu = new CrmMenu();
        crmMenu.setId(this.id);
        crmMenu.setName(this.name);
        crmMenu.setIcon(this.icon);
        crmMenu.setParentId(this.parentId);
        crmMenu.setMenuType(this.menuType);
        crmMenu.setOrderNum(this.orderNum);
        crmMenu.setComponent(this.component);
        crmMenu.setPath("/"+this.component);
        crmMenu.setPerms(this.perms);
        return crmMenu;
    }

    private Long id;
    /**
     * 菜单名称
     */
    private String name;

    /**
     * 菜单图标
     */
    private String icon;

    /**
     * 父菜单ID
     */
    private Long parentId;

    /**
     * 显示顺序
     */
    private Integer orderNum;

    /**
     * 路由地址
     */
    private String path;

    /**
     * 组件路径
     */
    private String component;

    /**
     * 菜单类型（M目录 C菜单 F按钮）
     */
    private String menuType;


    private String perms;


    private List<SysMenu> children = new ArrayList<>();

}